package com.finple;

import java.util.Random;

public class MeetingInfoVo {
	String pollId;
	String title;
	String password;
	String location;
	String description;
	String createTime;
	String initiatorAlias;
	String initiatorEmail;
	String pollTime;
	
	public MeetingInfoVo() {
		this.title = "";
		this.password = "";
		this.location = "";
		this.description = "";
		this.createTime = "";
		this.initiatorAlias = "";
		this.initiatorEmail = "";
		this.pollTime = "";
		this.pollId = "";
	}
	
	public MeetingInfoVo(String title, String password, String location, String description, String createTime,
			String initiatorAlias, String initiatorEmail, String pollTime, String pollId) {
		this.title = title;
		this.password = password;
		this.location = location;
		this.description = description;
		this.createTime = createTime;
		this.initiatorAlias = initiatorAlias;
		this.initiatorEmail = initiatorEmail;
		this.pollTime = pollTime;
		this.pollId = pollId;
	}

	@Override
	public String toString() {
		return "MeetingInfoVo [title=" + title + ", password=" + password + ", location=" + location + ", description="
				+ description + ", createTime=" + createTime + ", initiatorAlias=" + initiatorAlias
				+ ", initiatorEmail=" + initiatorEmail + ", pollTime=" + pollTime + ", pollId=" + pollId + "]";
	}
	
	public boolean hasNull() {
		if(title==null || password==null || location==null || description==null || 
				initiatorAlias==null || initiatorEmail==null || pollTime==null) {
			System.out.println("MeetingInfoVo [입력값중 null 값이 있기 때문에 DB 저장 안함]");
			return true;
		}
		else {
			return false;
		}
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getInitiatorAlias() {
		return initiatorAlias;
	}

	public void setInitiatorAlias(String initiatorAlias) {
		this.initiatorAlias = initiatorAlias;
	}

	public String getInitiatorEmail() {
		return initiatorEmail;
	}

	public void setInitiatorEmail(String initiatorEmail) {
		this.initiatorEmail = initiatorEmail;
	}

	public String getPollTime() {
		return pollTime;
	}

	public void setPollTime(String pollTime) {
		this.pollTime = pollTime;
	}
	
	public String getPollId() {
		return pollId;
	}

	public void setPollId(int length) {
		this.pollId = getRandomString(length);
	}

	/**
	 * 랜덤한 문자열을 원하는 길이만큼 반환한다.
	 * 
	 * @param length 문자열 길이
	 * @return 랜덤문자열
	 */
	private String getRandomString(int length)
	{
	  StringBuffer buffer =new StringBuffer();
	  Random random =new Random();
	 
	  String chars[]= 
	    "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9".split(",");
	 
	  for(int i=0; i<length ; i++)
	  {
	    buffer.append(chars[random.nextInt(chars.length)]);
	  }
	  
	  return buffer.toString();
	}
	
}
